home *** CD-ROM | disk | FTP | other *** search
- /*
- ***********************************************************************
- *
- *
- * Grayscale Image
- * Display an image on Macintosh
- *
- * The program converts an image to a pixmap in an offscreen Grafport
- * and has it displayed in a window
- *
- *
- ***********************************************************************
- */
-
- #include "image.h"
- #include "window.h"
-
- /*
- *----------------------------------------------------------------------
- * An instance of a generic screen window to display
- * an image
- */
-
- class MapWindow : public OffScreenWindow
- {
- public:
- MapWindow(const IMAGE& image, const char * title);
- ~MapWindow(void) {}
- };
-
-
- // Creating a window that would have our picture
- // displayed. This function also creates an
- // offscreen grafworld and draws the picture in it
- MapWindow::MapWindow(const IMAGE& image, const char * title)
- : OffScreenWindow((ScreenRect)image,title,256)
- {
- PixMapHandle pixmap = get_pixmap();
- assert( LockPixels(pixmap) );
-
- char * pixp = GetPixBaseAddr(pixmap);
- register int i; // "Draw" the image
- for(i=0; i<height(); i++, pixp += bytes_per_row())
- { // Note, bytes_per_row is generally GREATER
- register int j; // than width, and is always a multiple of 4
- for(j=0; j<width(); j++)
- pixp[j] = image(i,j);
- }
-
- UnlockPixels(pixmap);
- }
-
-
- /*
- *----------------------------------------------------------------------
- * Routing display function
- */
- void display_map(const IMAGE& image, const char * title)
- {
- MapWindow image_window(image,title);
- image_window.handle();
- }